<template>
  <div class="home">
    <home-header></home-header>
    <home-swiper :swiperList="swiperList"></home-swiper>
    <home-icons :iconList="iconList"></home-icons>
    <home-new></home-new>
    <home-selected :selectedList="selectedList"></home-selected>
    <home-recommend :recommendList="recommendList"></home-recommend>
    <home-reco :recoList="recoList"></home-reco>
    <home-culling :cullingList="cullingList"></home-culling>
    <home-nav :navList="navList"></home-nav>
  </div>
</template>

<script>
import axios from 'axios'
import HomeHeader from './components/HomeHeader'
import HomeSwiper from './components/HomeSwiper'
import HomeIcons from './components/HomeIcons'
import HomeNew from './components/HomeNew'
import HomeSelected from './components/HomeSelected'
import HomeRecommend from './components/HomeRecommend'
import HomeReco from './components/HomeReco'
import HomeCulling from './components/HomeCulling'
import HomeNav from './components/HomeNav'
export default {
  name: 'Home',
  data () {
    return {
      swiperList:[],
      iconList:[],
      selectedList:[],
      recommendList:[],
      recoList:[],
      cullingList:[],
      navList:[]
    }
  },
  components:{
      HomeHeader,
      HomeSwiper,
      HomeIcons,
      HomeNew,
      HomeSelected,
      HomeRecommend,
      HomeReco,
      HomeCulling,
      HomeNav,
  },mounted(){
    this.getHomeInfo()
  },
  methods:{
    getHomeInfo(){
        // axios返回的结果是一个promise对象
        axios.get('/shopping_mall/index.php').then(
        // 注意：这里绝对不可以写成this.getHomeInfoSucc（），否则请求的结果会是undefined
        this.getHomeInfoSucc
      )
    },
    getHomeInfoSucc(res){
        // console.log(res)
        res = res.data 
        // console.log(res)
        if(res.ret && res.data){
          this.swiperList = res.data.swiperList
          this.iconList = res.data.iconList
          this.selectedList = res.data.selectedList
          this.recommendList = res.data.recommendList
          this.recoList = res.data.recoList
          this.cullingList = res.data.cullingList
          this.navList = res.data.navList
        }
    }
  }
}
</script>


<style lang="stylus" scoped>
@import '../../assets/css/varibles.styl'
.home 
   background-color #efefef
</style>
